import { Body, Controller, Post, UseFilters } from '@nestjs/common';
import { AuthService } from './auth.service';
import { verityUserDto } from './dto/verity-user.dto';
import { TypeormFilter } from 'src/filters/typeorm.filter';

@Controller('auth')
@UseFilters(new TypeormFilter())  // 注入 typeOrm出错的过滤器
export class AuthController {
    constructor(
        private  authService:AuthService
    ){}

    @Post('/login')
    login(@Body() dto:verityUserDto ){
        let { username , password} = dto
        return this.authService.login(username,password)
    }

    @Post('/register')
    register(@Body() dto:verityUserDto ){
        let { username , password} = dto
        return this.authService.register(username,password)
    }

}
